package com.haiyisoft.eclipse.uep.visual.core;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.osgi.framework.BundleContext;

import com.haiyisoft.eclipse.common.CommonPlugin;

/**
 * The activator class controls the plug-in life cycle
 */
public class VisualCorePlugin extends CommonPlugin {

	// The plug-in ID
	public static final String PLUGIN_ID = "com.haiyisoft.eclipse.uep.visual.core"; //$NON-NLS-1$

	// The shared instance
	private static VisualCorePlugin plugin;
	
	public static final String DOT1_IMG = "icons/dot1.gif";
	public static final String DOT2_IMG = "icons/dot2.gif";
	public static final String DOT3_IMG = "icons/dot3.gif";
	
	/**
	 * The constructor
	 */
	public VisualCorePlugin() {
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext context) throws Exception {
		super.start(context);
		plugin = this;
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext context) throws Exception {
		plugin = null;
		super.stop(context);
	}

	/**
	 * Returns the shared instance
	 *
	 * @return the shared instance
	 */
	public static VisualCorePlugin getDefault() {
		return plugin;
	}
	
	@Override
	protected void initializeImageRegistry(ImageRegistry reg) {
		super.initializeImageRegistry(reg);
		registryDescriptor(reg, DOT1_IMG);
		registryDescriptor(reg, DOT2_IMG);
		registryDescriptor(reg, DOT3_IMG);
	}

	private void registryDescriptor(ImageRegistry reg, String path) {
		ImageDescriptor imageDesc = getImageDescriptor(PLUGIN_ID, path);
		reg.put(path, imageDesc);
	}

	public static ImageDescriptor getImageDescriptor(String pluginId,
			String path) {
		return imageDescriptorFromPlugin(pluginId, path);
	}
}
